#include <iostream>
#include <thread>

using std::cout;
using std::endl;
using std::thread;


void threadFunc(int x)
{
    cout << "child thread id " << std::this_thread::get_id() << endl;
    cout << "void threadFunc()" << endl;
    cout << "x = " << x << endl;
}

int main(int argc, char *argv[])
{
    cout << "main thread id " << std::this_thread::get_id() << endl;

    typedef void (&pFunc)(int);//pFunc就是函数引用
    pFunc f = threadFunc;

    thread th(f, 3);//th是子线程
    cout << "child thread id = " << th.get_id() << endl;
    th.join();//主线程等待子线程的退出

    return 0;
}

